<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" id="name">
    <input type="password" id="psd">
    <button id="login">登录</button>

    <script>
        document.getElementById('login').onclick = function() {
            var name = document.getElementById('name').value;
            var psd = document.getElementById('psd').value;

            var xhr = new XMLHttpRequest();
            var url = '04ajax_get.php?username=' + name + '&password=' + psd;
            xhr.open('get', url, true);
            xhr.send();
            xhr.onreadystatechange = function() {
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        console.log(xhr.responseText);

                    }

                }
            }
        }
    </script>
</body>

</html>